package com.sdry.model.llm;

import java.util.ArrayList;
import java.util.List;

/** 
* 菜单
* @author lian 
* @version 1.0
* @time 2018年10月18日 下午5:07:44
*/
public class Menu implements Comparable<Menu>{

	private Long id;
	/**
	 * 菜单名称
	 */
	private String name;  
	/**
	 * 访问路径
	 */
	private String url;  
	/**
	 * 类型（路径访问的是菜单，或是按钮）
	 */
	private String type; 
	/**
	 * 对应的父菜单的id
	 */
	private Long pid; 
	/**
	 * 排序，菜单排序
	 */
	private Long sort; 
	/**
	 * 子级菜单
	 */
	private List<Menu> children = new ArrayList<>();  
	public Menu(Long id, String name, String url, String type, Long pid, Long sort, List<Menu> children) {
		super();
		this.id = id;
		this.name = name;
		this.url = url;
		this.type = type;
		this.pid = pid;
		this.sort = sort;
		this.children = children;
	}
	public Menu() {
		super();
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Long getPid() {
		return pid;
	}
	public void setPid(Long pid) {
		this.pid = pid;
	}
	public Long getSort() {
		return sort;
	}
	public void setSort(Long sort) {
		this.sort = sort;
	}
	public List<Menu> getChildren() {
		return children;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((children == null) ? 0 : children.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((pid == null) ? 0 : pid.hashCode());
		result = prime * result + ((sort == null) ? 0 : sort.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		result = prime * result + ((url == null) ? 0 : url.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Menu other = (Menu) obj;
		if (children == null) {
			if (other.children != null)
				return false;
		} else if (!children.equals(other.children))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (pid == null) {
			if (other.pid != null)
				return false;
		} else if (!pid.equals(other.pid))
			return false;
		if (sort == null) {
			if (other.sort != null)
				return false;
		} else if (!sort.equals(other.sort))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		if (url == null) {
			if (other.url != null)
				return false;
		} else if (!url.equals(other.url))
			return false;
		return true;
	}
	public void setChildren(List<Menu> children) {
		this.children = children;
	}
	@Override
	public String toString() {
		return "Menu [id=" + id + ", name=" + name + ", url=" + url + ", type=" + type + ", pid=" + pid + ", sort="
				+ sort + ", children=" + children + "]";
	}
	@Override
	public int compareTo(Menu o) {
		return (int) (this.sort - o.getSort());
	}
	
}
